package jwdt.xadmin.system.service.impl;

import java.util.List;

import jwdt.common.dao.BaseDao;
import jwdt.common.util.CacheUtil;
import jwdt.xadmin.system.bean.FLMX;
import jwdt.xadmin.system.service.FlmxManageService;

import com.ezerg.db.Jdb;
import com.ezerg.db.ext.PageUtil;

public class FlmxManageServiceImpl implements FlmxManageService {
	
	private BaseDao<FLMX> baseDao;
	
	public void setBaseDao(BaseDao<FLMX> baseDao) {
		this.baseDao = baseDao;
	}
	
	@Override
	public PageUtil doList(PageUtil pu,int flid) throws Exception{
		String sql = " flid = "+flid+" order by px";
		pu.doList(FLMX.class,sql);
		//创造json数据对象
		return pu;
	}
	
	@SuppressWarnings("rawtypes")
	@Override
	public List doListForCombo(int flid) throws Exception {
		return Jdb.get().query("select mxdm, mxmc from jwdt_zd_flmx where flid=? and zt=1 ORDER BY px", new Object[]{flid}, CacheUtil.C0);
	}
	
	@Override
	public String doAddact(FLMX obj) throws Exception {
		return baseDao.doAddObj(obj);
	}

	@Override
	public String doEditact(FLMX obj, int id) throws Exception {
		return baseDao.doUpdateObj(FLMX.class, id, obj);
	};
	
	@Override
	public String doDelact(int id) throws Exception {
		return baseDao.doDelObj(FLMX.class, id);
	}

	@Override
	public FLMX doLoad(int id) throws Exception {
		return baseDao.doLoadObj(FLMX.class, id);
	}
	
	@Override
	public String doUpdateMxState(int id, int state) throws Exception {
		return baseDao.doIntUpdateState(FLMX.class, "mxdm='" + id + "'","zt=" + state);
	}
}
